package com.alatus.manager;

import com.alatus.constant.Constants;
import com.alatus.service.RedisService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.concurrent.TimeUnit;

@Component
public class RedisManager {
    @Resource
    private RedisService redisService;

    public Object getValue(String key){
        Object object = redisService.rangeAll(key);
        redisService.expire(key, Constants.DEFAULT_KEY_EXPIRE_TIME, TimeUnit.SECONDS);
        return object;
    }

    public <T> Object setValue(String key, Collection<T> data){
        Long result = redisService.listPush(key, data);
        redisService.expire(key, Constants.DEFAULT_KEY_EXPIRE_TIME, TimeUnit.SECONDS);
        return result;
    }
}
